//
//  MineAddAcountController.m
//  renmingongshe
//
//  Created by Mao on 2017/11/8.
//  Copyright © 2017年 xiaodian. All rights reserved.
//

#import "MineAddAcountController.h"

@interface MineAddAcountController ()
@property (weak, nonatomic) IBOutlet UITextField *name;
@property (weak, nonatomic) IBOutlet UITextField *phone;
@property (weak, nonatomic) IBOutlet UITextField *userId;
@property (weak, nonatomic) IBOutlet UITextField *acountTf;
@property (weak, nonatomic) IBOutlet UILabel *acountLb;

@end

@implementation MineAddAcountController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    self.view.backgroundColor = [UIColor colorWithHex:0xf2f2f2];
    self.titleLabel.text = @"添加账户";
    if (self.type == 1) {
        _acountLb.text = @"支付宝账号";
        _acountTf.placeholder = @"请输入支付宝账号";
    }else{
        _acountLb.text = @"微信账号";
        _acountTf.placeholder = @"请输入微信账号";
    }
}
- (IBAction)confirmClick:(id)sender {
    [self.view loadingOnAnyView];
    [THWManager PostHttp:API(MinePickAddCount) Parameters:@{@"userToken":[Utils getUserToken], @"accType":[NSString stringWithFormat:@"%ld", self.type], @"userName":_name.text, @"phone":_phone.text, @"userCardNo":_userId.text, @"accNo": _acountTf.text} Success:^(id responseObject) {
        [self.view removeAnyView];
        if ([String(responseObject[@"status_code"]) isEqualToString:@"1000"]) {
            [self.view Message:responseObject[@"msg"]];
            dispatch_time_t delayTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.5 * NSEC_PER_SEC));
            dispatch_after(delayTime, dispatch_get_main_queue(), ^{
                [self.navigationController popViewControllerAnimated:YES];
            });
        }else{
            [self.view Message:responseObject[@"msg"]];
        }
        
    } andFalse:^(NSError *error) {
        [self.view removeAnyView];
    }];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
